<template>
  <div class="about-master-container">
    <base-breadcrumb :breadcrumb="!isAudit">
      <a-form-model
        ref="RuleForm"
        :model="formData"
      >
        <a-tabs
          type="card"
          default-active-key="floors"
          class="card-tab"
          @change="getTabChange"
        >
          <a-tab-pane
            key="floors"
            tab="维保信息"
          >
            <div>
              <a-card
                v-loading="loading"
                :bordered="false"
              >
                <title-name title="基本信息" />
                <a-row>
                  <a-col span="8">
                    <a-form-model-item label="维保单编号">
                      <BaseInput
                        v-model="formData.code"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                   <a-col span="8">
                    <a-form-model-item
                      label="所属单位"
                      prop="projectId"
                    >
                      <OrgTreeSelect
                        v-model="formData.projectId"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="业态">
                      <BaseInput
                        v-model="formData.formats"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8">
                    <a-form-model-item label="合同维保截止时间">
                      <BaseInput
                        v-model="formData.maintenancePeriodCloseTime"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="质保金总额(万元)">
                      <BaseInputNumber
                        v-model="formData.amount"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>

                  <a-col span="8">
                    <a-form-model-item label="建设单位">
                      <BaseInput
                        v-model="formData.constructionUnit"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="竣工日期">
                      <BaseInput
                        v-model="formData.completionTime"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="维保年限">
                      <BaseInput
                        v-model="formData.maintenancePeriodYear"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-card>
              <a-card
                v-loading="loading"
                :bordered="false"
              >
                <title-name title="维保信息" />
                <a-row>
                  <a-col span="8">
                    <a-form-model-item label="维保发起人">
                      <BaseInput
                        v-model="formData.createUser"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="联系电话">
                      <BaseInput
                        v-model="formData.phone"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="维保发生周期">
                      <BaseInput
                        v-model="formData.maintenanceCycle"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="维保发起时间">
                      <BaseInput
                        v-model="formData.createTime"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8">
                    <a-form-model-item label="责任分包">
                      <BaseInput
                        v-model="formData.subContractorName"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="维修部位">
                      <BaseInput
                        v-model="formData.repairPosition"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="8">
                    <a-form-model-item label="维保事项">
                      <BaseInput
                        v-model="formData.infoName"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col :span="16">
                    <a-form-model-item label="维保诉求">
                      <BaseTextarea
                        v-model="formData.reason"
                        :max-length="10000"
                        disabled
                        placeholder="请输入"
                      />
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-card>
            </div>
          </a-tab-pane>
          <a-tab-pane
            v-if="formData.plan"
            key="floors-two"
            tab="维保方案信息"
          >
            <div>
              <a-card
                v-loading="loading"
                :bordered="false"
              >
                <title-name title="维保方案信息" />
                <a-row>
                  <a-col span="8">
                    <a-form-model-item label="维保方案编号">
                      <BaseInput
                        v-model="formData.plan.maintenancePlanCode"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="维保方案状态">
                      <BaseInput
                        v-model="formData.plan.maintenancePlanStatus"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="预计维保金额(万元)">
                      <BaseInput
                        v-model="formData.plan.maintenanceFee"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="实施分包单位">
                      <BaseInput
                        v-model="formData.plan.implementSubOrg"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="负责人">
                      <BaseInput
                        v-model="formData.plan.responsible"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="8">
                    <a-form-model-item label="维修计划完成时间">
                      <BaseInput
                        v-model="formData.plan.planCompletedTime"
                        disabled
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="24">
                    <a-form-model-item label="实施维修内容">
                      <BaseTextarea
                        v-model="formData.plan.implementContent"
                        :max-length="10000"
                        disabled
                        placeholder="请输入"
                      />
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-card>
            </div>
          </a-tab-pane>
          <a-tab-pane
            v-for="(item,index) in formData.handleData"
            :key="'floors-res' + index"
            :tab="'处理信息' + '(' + (index + 1) + ')'"
          >
            <a-card
              v-loading="loading"
              :bordered="false"
            >
              <title-name title="处理信息" />
              <a-row>
                <a-col span="8">
                  <a-form-model-item label="处理人">
                    <BaseInput
                      v-model="item.handler"
                      disabled
                    />
                  </a-form-model-item>
                </a-col>
                <a-col span="8">
                  <a-form-model-item label="处理时间">
                    <BaseInput
                      v-model="item.createTime"
                      disabled
                    />
                  </a-form-model-item>
                </a-col>
                <a-col span="8">
                  <a-form-model-item label="维保事项花费(万元)">
                    <BaseInputNumber
                      v-model="item.cost"
                      placeholder="请输入"
                      :max-length="1000"
                      :disabled="state == 3"
                    />
                  </a-form-model-item>
                </a-col>
                <a-col :span="24">
                  <a-form-model-item label="处理结果">
                    <BaseTextarea
                      v-model="item.handleResult"
                      :max-length="10000"
                      :disabled="state == 3"
                      placeholder="请输入"
                    />
                  </a-form-model-item>
                </a-col>
              </a-row>
            </a-card>
            <a-card
              v-loading="loading"
              :bordered="false"
            >
              <title-name title="相关附件" />
              <UploadTableNew
                ref="uploadTable"
                :disabled="state == 3"
                :mode="file.mode"
                :init-file-list="item.fileList"
                :need-page="false"
                :business-code="'CUSTOMER01'"
                :use-multi-delete="true"
                :use-multi-export="true"
              />
            </a-card>
          </a-tab-pane>

          <a-tab-pane
            key="floors-end"
            tab="满意调查信息"
          >
            <div>
              <a-card
                v-loading="loading"
                :bordered="false"
              >
                <title-name title="满意调查信息" />
                <a-row>
                  <a-col span="24">
                    <a-form-model-item label="调查内容">
                      <a-table
                        :pagination="false"
                        :columns="tableColumns"
                        :data-source="formData.tableData"
                        bordered
                      />
                    </a-form-model-item>
                  </a-col>
                  <a-col span="24">
                    <a-form-model-item label="调查意见或建议">
                      <BaseTextarea
                        v-model="formData.suggest"
                        :max-length="10000"
                        disabled
                        placeholder="请输入"
                      />
                    </a-form-model-item>
                  </a-col>
                </a-row>
              </a-card>
            </div>
          </a-tab-pane>
        </a-tabs>
      </a-form-model>

      <div class="pub-header-btn page-btn-right-top">
        <a-button
          v-checkVisibleInDetail
          @click="$close"
        >
          关闭
        </a-button>
      </div>
    </base-breadcrumb>
  </div>
</template>

<script>
import {
  planAddFile, planFileList, planFileListDel, planListDetail, print
} from '@/api/material/procurement/plan'
import { getCustomerComplaintById, } from '@/api/complaint/maintenance'
import SelectSubCompany from '@/components/Select/SelectSubCompany' // 分公司

export default {
  name: 'a' + Date.now(),
  props: {
    isAudit: {
      type: Boolean,
      default: false
    }
  },
  data () {
    return {
      tableColumns: [
        {
          title: '调查内容',
          dataIndex: 'name',
          width: '25%',
        },
        {
          title: '分值占比',
          dataIndex: 'numberzb',
          width: '25%',
        },
        {
          title: '分数配置',
          dataIndex: 'numberpz',
          width: '25%',
        },
        {
          title: '得分情况',
          dataIndex: 'getnumber',
          width: '25%',
        },
      ],
      key: '1',
      loading: false,
      state: Number(this.$route.query.state),
      isSubmit: false,
      row: this.$route.query.row,
      formData: {
        tableData: [],
      },
      file: {
        mode: this.$route.query.pageTyp === 'add' ? 'add' : 'edit',
        needPage: false,
        fileList: [],
        useMultiDelete: true,
        useMultiExport: true
      },
      planAddFile: planAddFile(),
      planFileList: planFileList(),
      planFileListDel: planFileListDel(),
    }
  },

  watch: {
    isAudit: {
      immediate: true,
      handler (val) {
        if (val) {
          this.state = 3
        }
      }
    },
  },
  mounted: function () {
    this.getDetail()
    this.isSubmit = true
  },
  methods: {
    getTabChange (e) {
      this.$checkRequireItem()
    },
    getDetail () {
      this.loading = true
      getCustomerComplaintById({ id: this.$route.query.id }).then(res => {
        if (res.data.subContractorId == null) {
          res.data.subContractorId = undefined
        }

        res.data.handleData = res.data.handList
        this.formData = res.data
        this.formData.tableData = [
          {
            name: '维保响应速度',
            numberzb: '25%',
            numberpz: '25',
            getnumber: res.data.responseScore ? res.data.responseScore : 0
          },
          {
            name: '质量管理',
            numberzb: '25%',
            numberpz: '25',
            getnumber: res.data.qualityScore ? res.data.qualityScore : 0

          }
          ,
          {
            name: '安全管理',
            numberzb: '25%',
            numberpz: '25',
            getnumber: res.data.securityScore ? res.data.securityScore : 0
          },
          {
            name: '服务水平',
            numberzb: '25%',
            numberpz: '25',
            getnumber: res.data.serviceScore ? res.data.serviceScore : 0

          }
        ]
        this.loading = false

      })
    },
  }
}
</script>